package com.eCommerce.webApp.common;


import java.util.PropertyResourceBundle;

import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;




import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ServiceFinder {
	public static Object findBean(String beanName){
		FacesContext context= FacesContext.getCurrentInstance();

		ServletContext servletContext = 
		    (ServletContext)context.getExternalContext().getContext();
		ApplicationContext appContext =
		    WebApplicationContextUtils.getWebApplicationContext(servletContext);

		Object o =appContext.getBean(beanName);

		return o;

	}

}
/*
 *  DOMConfigurator.configure(log4jConfigXmlFileName);
				bundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle("appresources.svco.spring.eCommerce-springSVCO");
				springTestFilename = bundle.getString("spring.eCommerce.svco.config.location");
				
				ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { springTestFilename });
			
 */
